import { Component, OnInit, ViewChild, OnDestroy, AfterContentInit } from '@angular/core';
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
import { NzMessageService, UploadFile, NzModalService, NzNotificationService } from 'ng-zorro-antd';
import { catchError } from 'rxjs/operators';
import { of } from 'rxjs';
import { ActivatedRoute, Router } from '@angular/router';
import {SettingsService, TitleService} from '@delon/theme';
import { Constant, ServiceResult } from '@core/constant';
import { maService } from '../../../../service/ma/ma.service';
import { EmitterService } from 'app/service/emit.service';
import { CommService } from '../../../../service/comm/comm.service';
import {insService} from "../../../../service/ins/ins.service";
import {ProductService} from "../../../../service/prod/product.service";
import {SimpleTableColumn, SimpleTableComponent} from "@delon/abc";
import {spListService} from "../../../../service/spList/spList.service";

@Component({
  selector: 'fh-detail-edit',
  templateUrl: './fh-detail.component.html',
  styleUrls: ['./fh-detail.component.less']
})
export class fhViewEditComponent implements OnInit, OnDestroy {


  checkedList = [];

  @ViewChild('st') st: SimpleTableComponent;
  columns: SimpleTableColumn[] = [
    { title: '103凭证', index: 'mblnr' },
    { title: '104凭证', index: 'qmRemark4' },

    { title: '质检员', index: 'qmRemark5' },

    { title: '105凭证', index: 'qmRemark6' },
    { title: '状态', index: 'vstatus' },

    { title: '快递单号', index: 'vbeln1' },
    { title: '供应商', index: 'lifnr' },
    { title: '供应商名称', index: 'name1' },
    { title: '发货时间', index: 'erdat' },
    { title: '采购订单', index: 'ebenl' },
    { title: '采购订单行项目', index: 'ebelp' },
    { title: '物料编码', index: 'matnr' },
    { title: '物料描述', index: 'maktx' },
    { title: '供应商物料编码', index: 'lifmatnr' },
    { title: '供应商物料描述', index: 'lifmatnr' },

    { title: '箱号', index: 'xianghao' },

    { title: '单位', index: 'meins' },
    { title: '数量', index: 'menge' },
    // { title: '收货数量', index: 'menge1' },
    // { title: '退货数量', index: 'menge2' },

    // { title: '行项目', index: 'zeile' },
    // { title: '年度', index: 'mjahr' },

    // { title: '实收数', index: 'menge1' },
    { title: '良品数', index: 'menge2' },
    { title: '不良品数', index: 'menge3' },
    { title: '抽检数量', index: 'qmMenge1' },
    { title: '不良比例', index: 'qmMenge2' },
    { title: '主要不良', index: 'qmRemark1' },
    { title: '质检备注', index: 'qmRemark2' },
    { title: '判定', index: 'qmPanding1' }
    // { title: '库存类型', index: 'zwxdkc' },
    // { title: '是否备料', index: 'zsfbl' }
    // { title: '城市代码 ', index: 'csdm' },
    // { title: '违章代码', index: 'wzid' },
    // { title: '查询批号', index: 'queryOrderno' }

  ];
  loading = false;
  constructor(
    private productService: ProductService,

    public setting: SettingsService,
    private msg: NzMessageService,
    private modalService: NzModalService,
    private maService: maService,
    private emit: EmitterService,
    private notice: NzNotificationService,
    private route: ActivatedRoute,
    private titleService: TitleService,
    private cnt: Constant,
    private router: Router,
    private comm: CommService,
    private spListService: spListService,

  ) {}
  ps=10;
  q: any = {
    ebeln: '',
    ebelp: '',
    matnr:'',
    maktx:'',
    vbeln:'',
    vbeln1:''
  };
  private sub: any;
url="";
  ngOnInit(): void {
    // 获取参数
    this.sub = this.route.params.subscribe(params => {
      this.q.ebeln = params["id"];
      this.q.ebelp = params["no"];

      // 获取商品详情
              this.url=this.spListService.listfh(this.q.ebeln);
    });
    // 隐藏reusetab
    // setTimeout(() => {
    //   this.emit.sendMessage("HIDE_REUSE_TAB");
    // }, 100);
    this.titleService.setTitle("发货显示")

  }
  loaddata(wqtype){
    // console.log(wqtype);
    // this.q.bpmStatus=wqtype;
    this.st.load(1,this.q)
  }
  // 显示reusetab
  ngOnDestroy() {
    this.emit.sendMessage("SHOW_REUSE_TAB");
  }
  back() {
    this.router.navigate(['/poList/poList']);
  }
  checkboxChange(list: any[]) {
    this.checkedList = list;
  }
  exportdetail() {
    if (this.checkedList.length > 0) {
      console.log("1*******");
      this.st.export(this.checkedList, { filename: '查询汇总.xlsx' });
    } else {
      this.notice.create('error', '失败', '请选择进行导出');

    }
  }
}
